/*     */ package com.zimbra.cs.client.soap;
/*     */ 
/*     */ import com.zimbra.common.auth.ZAuthToken;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.DomUtil;
/*     */ import com.zimbra.common.soap.SoapFaultException;
/*     */ import com.zimbra.common.soap.SoapHttpTransport;
/*     */ import com.zimbra.common.soap.SoapParseException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.LogFactory;
/*     */ import com.zimbra.common.util.StringUtil;
/*     */ import com.zimbra.cs.client.LmcContact;
/*     */ import com.zimbra.cs.client.LmcContactAttr;
/*     */ import com.zimbra.cs.client.LmcConversation;
/*     */ import com.zimbra.cs.client.LmcDocument;
/*     */ import com.zimbra.cs.client.LmcEmailAddress;
/*     */ import com.zimbra.cs.client.LmcFolder;
/*     */ import com.zimbra.cs.client.LmcMessage;
/*     */ import com.zimbra.cs.client.LmcMimePart;
/*     */ import com.zimbra.cs.client.LmcNote;
/*     */ import com.zimbra.cs.client.LmcSession;
/*     */ import com.zimbra.cs.client.LmcTag;
/*     */ import com.zimbra.cs.client.LmcWiki;
/*     */ import java.io.IOException;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.Iterator;
/*     */ import org.dom4j.QName;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class LmcSoapRequest
/*     */ {
/*  43 */   private static Log sLog = LogFactory.getLog(LmcSoapRequest.class);
/*     */   
/*  45 */   private static boolean sDumpXML = false;
/*  46 */   public static synchronized void setDumpXML(boolean b) { sDumpXML = b; }
/*     */   
/*  48 */   private static int sRetryCount = -1;
/*  49 */   public static synchronized void setRetryCount(int n) { sRetryCount = n; }
/*     */   
/*  51 */   private static int sTimeoutMillis = -1;
/*  52 */   public static synchronized void setTimeout(int millis) { sTimeoutMillis = millis; }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public LmcSession getSession()
/*     */   {
/*  61 */     return this.mSession;
/*     */   }
/*     */   
/*     */   public void setSession(LmcSession l) {
/*  65 */     this.mSession = l;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getRequestedAccountId()
/*     */   {
/*  75 */     return this.mRequestedAccountId;
/*     */   }
/*     */   
/*     */   public void setRequestedAccountId(String id) {
/*  79 */     this.mRequestedAccountId = id;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected LmcSession mSession;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected String mRequestedAccountId;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   protected abstract org.dom4j.Element getRequestXML()
/*     */     throws LmcSoapClientException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected abstract LmcSoapResponse parseResponseXML(org.dom4j.Element paramElement)
/*     */     throws SoapParseException, ServiceException, LmcSoapClientException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public LmcSoapResponse invoke(String targetURL)
/*     */     throws LmcSoapClientException, IOException, SoapFaultException, ServiceException, SoapParseException
/*     */   {
/* 115 */     LmcSoapResponse result = null;
/*     */     
/* 117 */     SoapHttpTransport trans = null;
/*     */     try {
/* 119 */       trans = new SoapHttpTransport(targetURL);
/* 120 */       trans.setTimeout(sTimeoutMillis);
/* 121 */       trans.setRetryCount(sRetryCount);
/* 122 */       trans.setUserAgent("lmc", null);
/*     */       
/*     */ 
/* 125 */       String curSessionID = null;
/* 126 */       if (this.mSession != null) {
/* 127 */         ZAuthToken zat = this.mSession.getAuthToken();
/* 128 */         trans.setAuthToken(zat);
/* 129 */         curSessionID = this.mSession.getSessionID();
/* 130 */         trans.setSessionId(curSessionID);
/*     */       }
/*     */       
/*     */ 
/* 134 */       org.dom4j.Element requestXML = getRequestXML();
/* 135 */       if (sDumpXML) {
/* 136 */         sLog.info("Request:" + DomUtil.toString(requestXML, true));
/*     */       }
/* 138 */       com.zimbra.common.soap.Element requestElt = com.zimbra.common.soap.Element.convertDOM(requestXML);
/*     */       org.dom4j.Element responseXML;
/*     */       org.dom4j.Element responseXML;
/* 141 */       if (this.mRequestedAccountId == null) {
/* 142 */         responseXML = trans.invoke(requestElt).toXML();
/*     */       } else
/* 144 */         responseXML = trans.invoke(requestElt, false, true, this.mRequestedAccountId).toXML();
/* 145 */       if (sDumpXML) {
/* 146 */         sLog.info("Response:" + DomUtil.toString(responseXML, true) + "\n");
/*     */       }
/*     */       
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 154 */       String newSessionID = trans.getSessionId();
/* 155 */       if ((newSessionID != null) && (this.mSession != null)) {
/* 156 */         if (curSessionID == null) {
/* 157 */           this.mSession.setSessionID(newSessionID);
/* 158 */         } else if (!curSessionID.equals(newSessionID)) {
/* 159 */           this.mSession.setSessionID(newSessionID);
/*     */         }
/*     */       }
/*     */       
/*     */ 
/* 164 */       result = parseResponseXML(responseXML);
/*     */     }
/*     */     finally {
/* 167 */       if (trans != null)
/* 168 */         trans.shutdown();
/*     */     }
/* 170 */     return result;
/*     */   }
/*     */   
/*     */ 
/*     */   protected LmcContact[] parseContactArray(org.dom4j.Element parentElem)
/*     */     throws ServiceException
/*     */   {
/* 177 */     ArrayList contactArray = new ArrayList();
/* 178 */     for (Iterator ait = parentElem.elementIterator("cn"); ait.hasNext();) {
/* 179 */       org.dom4j.Element a = (org.dom4j.Element)ait.next();
/* 180 */       contactArray.add(parseContact(a));
/*     */     }
/*     */     
/* 183 */     if (contactArray.isEmpty()) {
/* 184 */       return null;
/*     */     }
/* 186 */     LmcContact[] contacts = new LmcContact[contactArray.size()];
/* 187 */     return (LmcContact[])contactArray.toArray(contacts);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   protected static void addAttrNotNull(org.dom4j.Element elem, String attrName, String attrValue)
/*     */   {
/* 195 */     if (attrValue != null) {
/* 196 */       DomUtil.addAttr(elem, attrName, attrValue);
/*     */     }
/*     */   }
/*     */   
/*     */   protected void addContactAttr(org.dom4j.Element parent, LmcContactAttr attr)
/*     */   {
/* 202 */     String attrValue = attr.getAttrData();
/* 203 */     org.dom4j.Element newAttr = DomUtil.add(parent, "a", attrValue == null ? "" : attrValue);
/*     */     
/* 205 */     DomUtil.addAttr(newAttr, "n", attr.getAttrName());
/*     */   }
/*     */   
/*     */   protected LmcConversation parseConversation(org.dom4j.Element conv)
/*     */     throws LmcSoapClientException, ServiceException
/*     */   {
/* 211 */     LmcConversation result = new LmcConversation();
/*     */     
/*     */ 
/* 214 */     result.setID(conv.attributeValue("id"));
/* 215 */     result.setTags(conv.attributeValue("t"));
/* 216 */     String numMsgs = conv.attributeValue("n");
/* 217 */     if (numMsgs != null)
/* 218 */       result.setNumMessages(Integer.parseInt(numMsgs));
/* 219 */     result.setDate(conv.attributeValue("d"));
/* 220 */     result.setFlags(conv.attributeValue("f"));
/* 221 */     result.setFolder(conv.attributeValue("l"));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 228 */     ArrayList emailAddrs = new ArrayList();
/* 229 */     ArrayList msgs = new ArrayList();
/* 230 */     for (Iterator it = conv.elementIterator(); it.hasNext();) {
/* 231 */       org.dom4j.Element e = (org.dom4j.Element)it.next();
/*     */       
/*     */ 
/* 234 */       String elementType = e.getQName().getName();
/* 235 */       if (elementType.equals("fr"))
/*     */       {
/* 237 */         result.setFragment(e.getText());
/* 238 */       } else if (elementType.equals("e"))
/*     */       {
/* 240 */         LmcEmailAddress ea = parseEmailAddress(e);
/* 241 */         emailAddrs.add(ea);
/* 242 */       } else if (elementType.equals("su"))
/*     */       {
/* 244 */         result.setSubject(e.getText());
/* 245 */       } else if (elementType.equals("m"))
/*     */       {
/* 247 */         LmcMessage m = parseMessage(e);
/* 248 */         msgs.add(m);
/*     */       }
/*     */       else {
/* 251 */         throw new LmcSoapClientException("unknown element " + elementType + " within conversation");
/*     */       }
/*     */     }
/*     */     
/*     */ 
/*     */ 
/* 257 */     if (!emailAddrs.isEmpty()) {
/* 258 */       LmcEmailAddress[] a = new LmcEmailAddress[emailAddrs.size()];
/* 259 */       result.setParticipants((LmcEmailAddress[])emailAddrs.toArray(a));
/*     */     }
/* 261 */     if (!msgs.isEmpty()) {
/* 262 */       LmcMessage[] m = new LmcMessage[msgs.size()];
/* 263 */       result.setMessages((LmcMessage[])msgs.toArray(m));
/*     */     }
/* 265 */     return result;
/*     */   }
/*     */   
/*     */ 
/*     */   protected LmcContactAttr parseContactAttr(org.dom4j.Element cna)
/*     */     throws ServiceException
/*     */   {
/* 272 */     String attrName = DomUtil.getAttr(cna, "n");
/* 273 */     String attrID = cna.attributeValue("id");
/* 274 */     String ref = cna.attributeValue("ref");
/* 275 */     String attrData = cna.getText();
/*     */     
/* 277 */     LmcContactAttr lca = new LmcContactAttr(attrName, attrID, ref, attrData);
/* 278 */     return lca;
/*     */   }
/*     */   
/*     */ 
/*     */   protected LmcContact parseContact(org.dom4j.Element cn)
/*     */     throws ServiceException
/*     */   {
/* 285 */     LmcContact result = new LmcContact();
/*     */     
/*     */ 
/* 288 */     result.setID(DomUtil.getAttr(cn, "id"));
/* 289 */     result.setTags(cn.attributeValue("t"));
/* 290 */     result.setFlags(cn.attributeValue("f"));
/* 291 */     result.setFolder(cn.attributeValue("l"));
/*     */     
/*     */ 
/* 294 */     ArrayList cnAttrs = new ArrayList();
/* 295 */     for (Iterator ait = cn.elementIterator("a"); ait.hasNext();) {
/* 296 */       org.dom4j.Element cnAttrElem = (org.dom4j.Element)ait.next();
/* 297 */       cnAttrs.add(parseContactAttr(cnAttrElem));
/*     */     }
/* 299 */     if (!cnAttrs.isEmpty()) {
/* 300 */       LmcContactAttr[] cnAttrArray = new LmcContactAttr[cnAttrs.size()];
/* 301 */       result.setAttrs((LmcContactAttr[])cnAttrs.toArray(cnAttrArray));
/*     */     }
/*     */     
/*     */ 
/* 305 */     return result;
/*     */   }
/*     */   
/*     */   protected LmcMessage parseMessage(org.dom4j.Element msg)
/*     */     throws ServiceException, LmcSoapClientException
/*     */   {
/* 311 */     LmcMessage result = new LmcMessage();
/*     */     
/*     */ 
/* 314 */     result.setID(DomUtil.getAttr(msg, "id"));
/* 315 */     result.setFlags(msg.attributeValue("f"));
/* 316 */     String size = msg.attributeValue("s");
/* 317 */     if (size != null)
/* 318 */       result.setSize(Integer.parseInt(size));
/* 319 */     result.setContentMatched(msg.attributeValue("cm"));
/* 320 */     result.setDate(msg.attributeValue("d"));
/* 321 */     result.setConvID(msg.attributeValue("cid"));
/* 322 */     result.setFolder(msg.attributeValue("l"));
/* 323 */     result.setOriginalID(msg.attributeValue("origid"));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 330 */     ArrayList emailAddrs = new ArrayList();
/* 331 */     for (Iterator it = msg.elementIterator(); it.hasNext();) {
/* 332 */       org.dom4j.Element e = (org.dom4j.Element)it.next();
/*     */       
/*     */ 
/* 335 */       String elementType = e.getQName().getName();
/* 336 */       if (elementType.equals("fr"))
/*     */       {
/* 338 */         result.setFragment(e.getText());
/* 339 */       } else if (elementType.equals("e"))
/*     */       {
/* 341 */         LmcEmailAddress ea = parseEmailAddress(e);
/* 342 */         emailAddrs.add(ea);
/* 343 */       } else if (elementType.equals("su"))
/*     */       {
/* 345 */         result.setSubject(e.getText());
/* 346 */       } else if (elementType.equals("mp"))
/*     */       {
/* 348 */         LmcMimePart mp = parseMimePart(e);
/* 349 */         result.addMimePart(mp);
/* 350 */       } else if (elementType.equals("mid"))
/*     */       {
/* 352 */         result.setMsgIDHeader(e.getText());
/* 353 */       } else if (!elementType.equals("inv"))
/*     */       {
/*     */ 
/*     */ 
/* 357 */         throw new LmcSoapClientException("unknown element " + elementType + " within message");
/*     */       }
/*     */     }
/*     */     
/*     */ 
/* 362 */     if (!emailAddrs.isEmpty()) {
/* 363 */       LmcEmailAddress[] a = new LmcEmailAddress[emailAddrs.size()];
/* 364 */       result.setEmailAddresses((LmcEmailAddress[])emailAddrs.toArray(a));
/*     */     }
/*     */     
/* 367 */     return result;
/*     */   }
/*     */   
/*     */   protected LmcMimePart parseMimePart(org.dom4j.Element mp)
/*     */     throws LmcSoapClientException, ServiceException
/*     */   {
/* 373 */     LmcMimePart result = new LmcMimePart();
/*     */     
/*     */ 
/* 376 */     result.setPartName(DomUtil.getAttr(mp, "part"));
/* 377 */     result.setIsBody(mp.attributeValue("body"));
/* 378 */     result.setSize(mp.attributeValue("s"));
/* 379 */     result.setMessageID(mp.attributeValue("mid"));
/* 380 */     result.setConvID(mp.attributeValue("cid"));
/* 381 */     result.setContentType(mp.attributeValue("ct"));
/* 382 */     result.setContentTypeName(mp.attributeValue("name"));
/* 383 */     result.setContentDisp(mp.attributeValue("cd"));
/* 384 */     result.setContentDispFilename(mp.attributeValue("filename"));
/*     */     
/* 386 */     result.setContentDesc(mp.attributeValue("cde"));
/*     */     
/*     */ 
/* 389 */     ArrayList subMimeParts = new ArrayList();
/* 390 */     for (Iterator it = mp.elementIterator(); it.hasNext();) {
/* 391 */       org.dom4j.Element e = (org.dom4j.Element)it.next();
/*     */       
/*     */ 
/* 394 */       String elementType = e.getQName().getName();
/* 395 */       if (elementType.equals("content")) {
/* 396 */         addContent(result, e);
/* 397 */       } else if (elementType.equals("mp")) {
/* 398 */         LmcMimePart nextPart = parseMimePart(e);
/* 399 */         subMimeParts.add(nextPart);
/*     */       }
/*     */       else {
/* 402 */         throw new LmcSoapClientException("unexpected element " + elementType);
/*     */       }
/*     */     }
/*     */     
/*     */ 
/* 407 */     if (!subMimeParts.isEmpty()) {
/* 408 */       LmcMimePart[] mpArr = new LmcMimePart[subMimeParts.size()];
/* 409 */       result.setSubParts((LmcMimePart[])subMimeParts.toArray(mpArr));
/*     */     }
/* 411 */     return result;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected void addContent(LmcMimePart mp, org.dom4j.Element c)
/*     */   {
/* 421 */     mp.setContentEncoding(c.attributeValue("cte"));
/* 422 */     mp.setContent(c.getText());
/*     */   }
/*     */   
/*     */   protected LmcEmailAddress parseEmailAddress(org.dom4j.Element ea) {
/* 426 */     LmcEmailAddress result = new LmcEmailAddress();
/*     */     
/*     */ 
/* 429 */     result.setType(ea.attributeValue("t"));
/* 430 */     result.setEmailID(ea.attributeValue("id"));
/* 431 */     result.setReferencedID(ea.attributeValue("ref"));
/* 432 */     result.setPersonalName(ea.attributeValue("p"));
/* 433 */     result.setEmailAddress(ea.attributeValue("a"));
/* 434 */     result.setDisplayName(ea.attributeValue("d"));
/*     */     
/*     */ 
/* 437 */     result.setContent(ea.getText());
/*     */     
/* 439 */     return result;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected LmcFolder parseFolder(org.dom4j.Element f)
/*     */     throws ServiceException
/*     */   {
/* 451 */     LmcFolder response = new LmcFolder();
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 458 */     response.setFolderID(DomUtil.getAttr(f, "id"));
/* 459 */     response.setName(f.attributeValue("name"));
/* 460 */     response.setParentID(f.attributeValue("l"));
/* 461 */     response.setNumUnread(f.attributeValue("u"));
/* 462 */     response.setView(f.attributeValue("view"));
/*     */     
/*     */ 
/* 465 */     ArrayList subFolders = new ArrayList();
/* 466 */     for (Iterator ait = f.elementIterator("folder"); ait.hasNext();) {
/* 467 */       org.dom4j.Element sub = (org.dom4j.Element)ait.next();
/* 468 */       subFolders.add(parseFolder(sub));
/*     */     }
/* 470 */     if (!subFolders.isEmpty()) {
/* 471 */       LmcFolder[] fs = new LmcFolder[subFolders.size()];
/* 472 */       response.setSubFolders((LmcFolder[])subFolders.toArray(fs));
/*     */     }
/* 474 */     return response;
/*     */   }
/*     */   
/*     */ 
/*     */   protected void addPrefToMultiMap(HashMap prefMap, org.dom4j.Element e)
/*     */     throws ServiceException
/*     */   {
/* 481 */     String name = DomUtil.getAttr(e, "name");
/* 482 */     String value = e.getText();
/* 483 */     StringUtil.addToMultiMap(prefMap, name, value);
/*     */   }
/*     */   
/*     */   protected LmcNote parseNote(org.dom4j.Element n)
/*     */     throws ServiceException
/*     */   {
/* 489 */     LmcNote result = new LmcNote();
/*     */     
/*     */ 
/* 492 */     result.setID(DomUtil.getAttr(n, "id"));
/* 493 */     result.setTags(n.attributeValue("t"));
/* 494 */     result.setDate(DomUtil.getAttr(n, "d"));
/* 495 */     result.setFolder(DomUtil.getAttr(n, "l"));
/* 496 */     result.setPosition(DomUtil.getAttr(n, "pos"));
/* 497 */     result.setColor(DomUtil.getAttr(n, "color"));
/*     */     
/*     */ 
/* 500 */     org.dom4j.Element c = DomUtil.get(n, "content");
/* 501 */     result.setContent(c.getText());
/*     */     
/* 503 */     return result;
/*     */   }
/*     */   
/*     */   protected LmcTag parseTag(org.dom4j.Element t)
/*     */     throws ServiceException
/*     */   {
/* 509 */     String name = DomUtil.getAttr(t, "name");
/* 510 */     String id = DomUtil.getAttr(t, "id");
/* 511 */     String color = DomUtil.getAttr(t, "color");
/* 512 */     long unreadCount = DomUtil.getAttrLong(t, "u", -1L);
/* 513 */     LmcTag newTag = unreadCount == -1L ? new LmcTag(id, name, color) : new LmcTag(id, name, color, unreadCount);
/*     */     
/* 515 */     return newTag;
/*     */   }
/*     */   
/*     */   protected LmcDocument parseDocument(org.dom4j.Element doc) {
/* 519 */     LmcDocument result = parseDocumentCommon(doc, new LmcDocument());
/* 520 */     return result;
/*     */   }
/*     */   
/*     */   protected LmcWiki parseWiki(org.dom4j.Element wiki) {
/* 524 */     LmcWiki result = new LmcWiki();
/* 525 */     parseDocumentCommon(wiki, result);
/*     */     
/* 527 */     result.setWikiWord(wiki.attributeValue("name"));
/*     */     try
/*     */     {
/* 530 */       org.dom4j.Element c = DomUtil.get(wiki, "body");
/* 531 */       result.setContents(c.getText());
/*     */     }
/*     */     catch (Exception e) {}
/* 534 */     return result;
/*     */   }
/*     */   
/*     */   private LmcDocument parseDocumentCommon(org.dom4j.Element doc, LmcDocument result) {
/* 538 */     result.setID(doc.attributeValue("id"));
/* 539 */     result.setName(doc.attributeValue("name"));
/* 540 */     result.setContentType(doc.attributeValue("ct"));
/* 541 */     result.setFolder(doc.attributeValue("l"));
/* 542 */     result.setRev(doc.attributeValue("ver"));
/* 543 */     result.setLastModifiedDate(doc.attributeValue("d"));
/* 544 */     result.setLastEditor(doc.attributeValue("leb"));
/* 545 */     result.setRestUrl(doc.attributeValue("rest"));
/* 546 */     result.setCreator(doc.attributeValue("cr"));
/* 547 */     result.setCreateDate(doc.attributeValue("cd"));
/*     */     
/* 549 */     for (Iterator it = doc.elementIterator(); it.hasNext();) {
/* 550 */       org.dom4j.Element e = (org.dom4j.Element)it.next();
/*     */       
/* 552 */       String elementType = e.getQName().getName();
/* 553 */       if (elementType.equals("fr"))
/*     */       {
/* 555 */         result.setFragment(e.getText());
/*     */       }
/*     */     }
/* 558 */     return result;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected void addMsg(org.dom4j.Element e, LmcMessage msg, String inReplyTo, String fwdMsgID, String[] fwdPartNumbers)
/*     */   {
/* 571 */     org.dom4j.Element m = DomUtil.add(e, "m", "");
/*     */     
/*     */ 
/* 574 */     addAttrNotNull(m, "origid", msg.getOriginalID());
/* 575 */     addAttrNotNull(m, "l", msg.getFolder());
/* 576 */     addAttrNotNull(m, "tag", msg.getTag());
/*     */     
/*     */ 
/* 579 */     LmcEmailAddress[] addrs = msg.getEmailAddresses();
/* 580 */     for (int i = 0; (addrs != null) && (i < addrs.length); i++) {
/* 581 */       addEmailAddress(m, addrs[i]);
/*     */     }
/*     */     
/* 584 */     DomUtil.add(m, "su", msg.getSubject());
/*     */     
/*     */ 
/* 587 */     String content = msg.getContent();
/* 588 */     if (content != null) {
/* 589 */       DomUtil.add(m, "content", content);
/*     */     }
/*     */     
/* 592 */     if (inReplyTo != null) {
/* 593 */       DomUtil.add(m, "irt", inReplyTo);
/*     */     }
/*     */     
/* 596 */     LmcMimePart mp = msg.getMimePart(0);
/* 597 */     if (mp != null) {
/* 598 */       addMimePart(m, mp);
/*     */     }
/*     */     
/* 601 */     String[] attachmentIDs = msg.getAttachmentIDs();
/* 602 */     if (attachmentIDs != null) {
/* 603 */       for (int i = 0; i < attachmentIDs.length; i++) {
/* 604 */         org.dom4j.Element aid = DomUtil.add(m, "attach", "");
/* 605 */         addAttrNotNull(aid, "aid", attachmentIDs[i]);
/*     */       }
/*     */     }
/*     */     
/*     */ 
/* 610 */     if (fwdPartNumbers != null) {
/* 611 */       org.dom4j.Element attach = DomUtil.add(m, "attach", "");
/* 612 */       for (int i = 0; i < fwdPartNumbers.length; i++) {
/* 613 */         org.dom4j.Element part = DomUtil.add(attach, "mp", "");
/* 614 */         DomUtil.addAttr(part, "mid", fwdMsgID);
/* 615 */         DomUtil.addAttr(part, "part", fwdPartNumbers[i]);
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected void addMimePart(org.dom4j.Element m, LmcMimePart mp)
/*     */   {
/* 628 */     org.dom4j.Element mpElem = DomUtil.add(m, "mp", "");
/* 629 */     addAttrNotNull(mpElem, "part", mp.getPartName());
/* 630 */     addAttrNotNull(mpElem, "body", mp.getIsBody());
/* 631 */     addAttrNotNull(mpElem, "s", mp.getSize());
/* 632 */     addAttrNotNull(mpElem, "mid", mp.getMessageID());
/* 633 */     addAttrNotNull(mpElem, "cid", mp.getConvID());
/* 634 */     addAttrNotNull(mpElem, "ct", mp.getContentType());
/* 635 */     addAttrNotNull(mpElem, "name", mp.getContentTypeName());
/* 636 */     addAttrNotNull(mpElem, "cd", mp.getContentDisp());
/* 637 */     addAttrNotNull(mpElem, "filename", mp.getContentDispFilename());
/*     */     
/*     */ 
/* 640 */     String content = mp.getContent();
/* 641 */     if (content != null) {
/* 642 */       org.dom4j.Element cElem = DomUtil.add(mpElem, "content", content);
/* 643 */       addAttrNotNull(cElem, "cte", mp.getContentEncoding());
/*     */     }
/*     */     
/*     */ 
/* 647 */     LmcMimePart[] subParts = mp.getSubParts();
/* 648 */     for (int i = 0; (subParts != null) && (i < subParts.length); i++) {
/* 649 */       addMimePart(mpElem, subParts[i]);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected void addEmailAddress(org.dom4j.Element m, LmcEmailAddress addr)
/*     */   {
/* 659 */     String content = addr.getContent();
/* 660 */     org.dom4j.Element e = DomUtil.add(m, "e", content == null ? "" : content);
/*     */     
/* 662 */     addAttrNotNull(e, "t", addr.getType());
/* 663 */     addAttrNotNull(e, "a", addr.getEmailAddress());
/* 664 */     addAttrNotNull(e, "p", addr.getPersonalName());
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/client/soap/LmcSoapRequest.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */